import os

import yaml


def load_config(file_path):
    """
    加载配置文件
    """
    with open(file_path, 'r') as file:
        config = yaml.safe_load(file)
    return config


def load_config_file(file_name):
    """
    使用给定文件名加载配置文件
    """
    current_dir = os.path.dirname(os.path.abspath(__file__))
    config_path = os.path.join(current_dir, f'../configs/{file_name}')
    return load_config(config_path)


class ConfigLoader(object):

    @staticmethod
    def load_milvus_config():
        """
        加载 Milvus 配置
        """
        return load_config_file('milvus_config.yaml')['milvus']

    @staticmethod
    def load_mysql_config():
        """
        加载 MySQL 配置
        """
        return load_config_file('mysql_config.yaml')['mysql']

    @staticmethod
    def load_chat_config():
        """
        加载 Chat 配置
        """
        return load_config_file('chat_config.yaml')['chat']

    @staticmethod
    def load_embedding_config():
        """
        加载嵌入模型配置
        """
        return load_config_file('embedding_config.yaml')['embedding']


def main():
    config_files = ['milvus_config.yaml', 'mysql_config.yaml', 'chat_config.yaml', 'embedding_config.yaml']

    for file_name in config_files:
        config = load_config_file(file_name)
        print(f"{file_name.capitalize().replace('_', ' ')}:", config)


if __name__ == "__main__":
    main()
